home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / utility / mu17_ext.zip / MULTIUSE.DEF < prev    next >
Text File  |  1994-03-07  |  12KB  |  455 lines

  1. DEFINITION MODULE MultiUserD; (*$ Implementation:=FALSE *)
  2. (* Frank J. Beckmann    22.10.1993 *)
  3.  
  4.  
  5. FROM SYSTEM IMPORT
  6.  ADDRESS;
  7.  
  8. FROM ExecD IMPORT
  9.  MinNode, TaskPtr, MsgPortPtr, Message;
  10. FROM UtilityD IMPORT
  11.  tagUser;
  12.  
  13.  
  14. CONST
  15.  multiUserName="multiuser.library";
  16.  
  17.  
  18. (*
  19.         Reserved users/groups
  20.     
  21.         WARNING: a uid may NOT be zero, a gid may be zero
  22. *)
  23.  
  24. CONST
  25.  ownerNobody=0;
  26.  ownerSystem=MAX(LONGCARD);
  27.  
  28.  rootUid=MAX(CARDINAL);
  29.  rootGid=MAX(CARDINAL);
  30.  
  31.  nobodyUid=0;
  32.  
  33.  useridsize=32;
  34.  groupidsize=32;
  35.  passwordsize=32;
  36.  usernamesize=220;
  37.  groupnamesize=220;
  38.  homedirsize=256;
  39.  
  40.  
  41. (*
  42.         Password File
  43.     
  44.     
  45.         For each user, the Password File must contain a line like this:
  46.     
  47.         <UserID>|<Password>|<uid>|<gid>|<UserName>|<HomeDir>|<Shell>
  48.     
  49.         with:
  50.     
  51.            <UserID>    User Login ID (max. muUSERIDSIZE-1 characters)
  52.            <PassKey>   Encrypted Password
  53.            <uid>       User Number (1 - 65535)
  54.            <gid>       Primary Group Number (0 - 65535)
  55.            <UserName>  Full User Name (max. muUSERNAMESIZE-1 characters)
  56.            <HomeDir>   Home directory (max. muHOMEDIRSIZE-1 characters)
  57.            <Shell>     Default Shell (not used yet, AS225 compatibility)
  58. *)
  59.  
  60. CONST
  61.  passwdFileName="passwd";  (* for AS225 compatibility *)
  62.  
  63.  
  64. (*
  65.         Group File
  66.     
  67.     
  68.         This file gives more information about the groups and defines
  69.         the secondary groups (other than the primary group) a user
  70.         belongs to. It exists out of two parts, separated by a blank line.
  71.     
  72.         The first part contains lines with the format:
  73.     
  74.         <GroupID>|<gid>|<MgrUid>|<GroupName>
  75.     
  76.         with:
  77.     
  78.            <GroupID>   Group short ID (max. muGROUPIDSIZE-1 characters)
  79.            <gid>       Group Number (0 - 65535)
  80.            <MgrUid>    User Number of this group's manager, 0 for no
  81.                        manager. A group's manager must not belong to the
  82.                        group.
  83.            <GroupName> Full Group Name (max. muGROUPNAMESIZE-1 characters)
  84.     
  85.         NOTE: Not every group must have a line in this file, but at least
  86.               one group must have one.
  87.     
  88.     
  89.         The seconds part contains lines with the format:
  90.     
  91.         <uid>:<gid>[,<gid>...]
  92.     
  93.         with:
  94.     
  95.            <uid>       User Number (1 - 65535)
  96.            <gid>       Group Number (0 - 65535)
  97.     
  98.         If you think you'll exceed the maximum line length (circa 1K),
  99.         you may use more than one line per user.
  100. *)
  101.  
  102. CONST
  103.  groupFileName="MultiUser.group";
  104.  
  105.  
  106. (*
  107.         Configuration File
  108.     
  109.     
  110.         This file contains lines with options in the form <OPT>=<val>.
  111.         0 is used for OFF, 1 for ON.
  112.         Defaults to the values between square brackets.
  113.     
  114.         LIMITDOSSETPROTECTION   dos.library/SetProtection() cannot change
  115.                                 protection bits for GROUP and OTHER [1]
  116.         PROFILE                 execute the Profile if it exists [1]
  117.         LASTLOGINREQ            display the Lastlogin requester [1]
  118.         LOGSTARTUP              log startup [0]
  119.         LOGLOGIN                log successful logins [0]
  120.         LOGLOGINFAIL            log failed logins [0]
  121.         LOGPASSWD               log successful password changes [0]
  122.         LOGPASSWDFAIL           log failed password changes [0]
  123.         LOGCHECKPASSWD          log successful password checks [0]
  124.         LOGCHECKPASSWDFAIL      log failed password checks [0]
  125.         PASSWDUIDLEVEL          users with a uid greather than or equal to
  126.                                 <val> can change their passwords [0]
  127.         PASSWDGIDLEVEL          users with a gid greather than or equal to
  128.                                 <val> can change their passwords [0]
  129.     
  130.         NOTE: if a user has a uid less than the PASSWDUIDLEVEL AND a gid
  131.               less than PASSWDGIDLEVEL he/she is NOT allowed to change
  132.               his/her password!
  133. *)
  134.  
  135. CONST
  136.  configFileName="MultiUser.config";
  137.  
  138.  
  139. (*
  140.         Log File
  141. *)
  142.  
  143. CONST
  144.  logFileName="MultiUser.log";
  145.  
  146.  
  147. (*
  148.         Lastlogin File
  149. *)
  150.  
  151. CONST
  152.  lastLoginFileName=".lastlogin";
  153.  
  154.  
  155. (*
  156.         Profile
  157. *)
  158.  
  159. CONST
  160.  profileFileName=".profile";
  161.  
  162.  
  163. (*
  164.         Plan file
  165. *)
  166.  
  167. CONST
  168.  planFileName=".plan";
  169.  
  170.  
  171. (*
  172.         Key File
  173.     
  174.     
  175.         This file must be present in the root directory of every volume
  176.         that uses the MultiUserFileSystem. It must contain 3 lines:
  177.     
  178.            - a pseudo random ASCII key (max. 1023 characters).
  179.            - the directory of the password file, if located on this volume,
  180.              otherwise an empty line (no spaces!).
  181.                e.g. ":inet/db" for AS225 compatibility
  182.            - the directory of the configuration file, if located on this
  183.              volume, otherwise an empty line (no spaces!).
  184.                e.g. ":MultiUser"
  185.     
  186.         If there is ANY inconsistency the system will refuse to work!!
  187. *)
  188.  
  189. CONST
  190.  keyFileName=":.MultiUser.keyfile";
  191.  
  192.  
  193. (*
  194.         Tags for muLogoutA()
  195.                  muLoginA()
  196.                  muSetDefProtectionA()
  197. *)
  198.  
  199. TYPE
  200.  muTags=(
  201.   muInput:=tagUser+1,    (* filehandle - default is Input() *)
  202.   muOutput,        (* filehandle - default is Output() *)
  203.   muGraphical,        (* boolean - default is FALSE *)
  204.   muPubScrName,        (* name of public screen *)
  205.   muTask,        (* task (NOT the name!!) *)
  206.   muOwn,        (* make a task owned by this user *)
  207.   muGlobal,        (* change it for all tasks on the *)
  208.             (* same level as this one *)
  209.   muQuiet,        (* for muLogoutA(), don't give a *)
  210.             (* login prompt, simply logout *)
  211.   muUserID,        (* UserID for muLoginA(), must be *)
  212.               (* used together with muT_Password!! *)
  213.   muPassword,        (* Password for muLoginA(), must be *)
  214.             (* used together with muT_UserID!! *)
  215.   muDefProtection,    (* Default protection bits *)
  216.               (* default is RWED GROUP R OTHER R *)
  217.   muAll            (* for muLogoutA(), logout until *)
  218.             (* user stack is empty *)
  219.  );
  220.  
  221.  
  222. (*
  223.         Public User Information Structure
  224.     
  225.     
  226.         For future compatibility, you should ALWAYS use muAllocUserInfo()
  227.         to allocate this structure. NEVER do it by yourself!!
  228. *)
  229.  
  230. TYPE
  231.  UserInfo=RECORD
  232.   userID: ARRAY [0..useridsize-1] OF CHAR;
  233.   uid: CARDINAL;
  234.   gid: CARDINAL;
  235.   userName: ARRAY [0..usernamesize-1] OF CHAR;
  236.   homeDir: ARRAY [0..homedirsize-1] OF CHAR;
  237.   numSecGroups: CARDINAL;        (* Number of Secondary Groups this *)
  238.                       (* user belongs to *)
  239.   secGroups: ADDRESS;            (* POINTER TO ARRAY OF CARDINAL *)
  240.                       (* Points to an array of NumSecGroups *)
  241.                       (* Secondary Group Numbers *)
  242.  END;
  243.  
  244.  UserInfoPtr=POINTER TO UserInfo;
  245.  
  246.  
  247. (*
  248.         Public Group Information Structure
  249.     
  250.     
  251.         For future compatibility, you should ALWAYS use muAllocGroupInfo()
  252.         to allocate this structure. NEVER do it by yourself!!
  253. *)
  254.  
  255. TYPE
  256.  GroupInfo=RECORD
  257.   groupID: ARRAY [0..groupidsize-1] OF CHAR;
  258.   gid: CARDINAL;
  259.   mgrUid: CARDINAL;                (* Manager of this group *)
  260.   groupName: ARRAY [0..groupnamesize-1] OF CHAR;
  261.  END;
  262.  
  263.  GroupInfoPtr=POINTER TO GroupInfo;
  264.  
  265.  
  266. (*
  267.         KeyTypes for muGetUserInfo()
  268.                      muGetGroupInfo()
  269. *)
  270.  
  271. CONST
  272.  keyTypeFirst=0;
  273.  keyTypeNext=1;
  274.  keyTypeGid=4;
  275.  
  276.  
  277. (*
  278.         KeyTypes for muGetUserInfo() only
  279. *)
  280.  
  281. CONST
  282.  keyTypeUserID=2;
  283.  keyTypeUid=3;
  284.  keyTypeGidNext=5;
  285.  keyTypeUserName=6;        (* Case-insensitive *)
  286.  keyTypeWUserID=7;        (* Case-insensitive, wild cards allowed *)
  287.  keyTypeWUserName=8;        (* Case-insensitive, wild cards allowed *)
  288.  keyTypeWUserIDNext=9;
  289.  keyTypeWUserNameNext=10;
  290.  
  291.  
  292. (*
  293.         KeyTypes for muGetGroupInfo() only
  294. *)
  295.  
  296. CONST
  297.  keyTypeGroupID=11;        (* Case-sensitive *)
  298.  keyTypeWGroupID=12;        (* Case-insensitive, wild cards allowed *)
  299.  keyType_WGroupIDNext=13;
  300.  keyTypeGroupName=14;        (* Case-insensitive *)
  301.  keyTypeWGroupName=15;        (* Case-insensitive, wild cards allowed *)
  302.  keyTypeWGroupNameNext=16;
  303.  keyTypeMgrUid=17;
  304.  keyTypeMgrUidNext=18;
  305.  
  306.  
  307. (*
  308.         Extended Owner Information Structure
  309.     
  310.     
  311.         A pointer to this structure is returned by muGetTaskExtOwner().
  312.         You MUST use muFreeExtOwner() to deallocate it!!
  313. *)
  314.  
  315. TYPE
  316.  ExtOwner=RECORD
  317.   uid: CARDINAL;
  318.   gid: CARDINAL;
  319.   numSecGroups: CARDINAL;    (* Number of Secondary Groups this *)
  320.                   (* user belongs too. *)
  321.  END;
  322.  
  323.  (* NOTE: This structure is followed by a UWORD array containing *)
  324.  (*       the Secondary Group Numbers *)
  325.  
  326.  ExtOwnerPtr=POINTER TO ExtOwner;
  327.  
  328.  
  329. (*
  330.     Portectionn bits
  331. *)
  332.  
  333.  (* Regular RWED bits are 0 == allowed. *)
  334.  (* NOTE: GRP and OTR RWED permissions are 0 == not allowed! *)
  335.  
  336. TYPE
  337.  ProtectionFlags=(
  338.   delete,        (* prevent file from being deleted *)
  339.   execute,        (* ignored by system, used by Shell *)
  340.   write,        (* ignored by old filesystem *)
  341.   read,            (* ignored by old filesystem *)
  342.   archive,        (* cleared whenever file is changed *)
  343.   pure,            (* program is reentrant and rexecutable *)
  344.   script,        (* program is a script (execute) file *)
  345.   
  346.   grpDelete,        (* Group: prevent file from being deleted *)
  347.   grpExecute,        (* Group: file is executable *)
  348.   grpWrite,        (* Group: file is writable *)
  349.   grpRead,        (* Group: file is readable *)
  350.   otrDelete,        (* Other: prevent file from being deleted *)
  351.   otrExecute,        (* Other: file is executable *)
  352.   otrWrite,        (* Other: file is writable *)
  353.   otrRead,        (* Other: file is readable *)
  354.   pf16, pf17, pf18, pf19, pf20, pf21, pf22, pf23, 
  355.   pf24, pf25, pf26, pf27, pf28, pf29, pf30,
  356.   setUid        (* Change owner during execution *)
  357.  );
  358.  
  359.  ProtectionFlagSet=SET OF ProtectionFlags;
  360.  
  361.  
  362. (*
  363.         Default Protection Bits
  364. *)
  365.  
  366. CONST
  367.  defprotection=ProtectionFlagSet{otrRead, grpRead};
  368.  
  369.  
  370. (*
  371.         Relations returned by muGetRelationshipA()
  372. *)
  373.  
  374. TYPE
  375.  Relations=(
  376.   relbRootUid,            (* User == super user *)
  377.   relbRootGid,            (* User belongs to the super user group *)
  378.   relbNobody,            (* User == nobody *)
  379.   relbUidMatch,            (* User == owner *)
  380.   relbGidMatch,            (* User belongs to owner group *)
  381.   relbPrimGid,            (* User's primary group == owner group *)
  382.   relbNoOwner            (* Owner == nobody *)
  383.  );
  384.  
  385.  RelationSet=SET OF Relations;
  386.  
  387.  
  388. (*
  389.         Monitor Structure
  390.     
  391.     
  392.         The use of this structure is restricted to root.
  393.         Do not modify or reuse this structure while it is active!
  394. *)
  395.  
  396. TYPE
  397.  MonitorModes=(ignore, sendSignal, sendMessage);
  398.  
  399.  MonitorTriggers=(
  400.   mtOwnerChange,        (* Task Owner Change *)
  401.                   (*    From:    uid of old user *)
  402.                   (*    To:      uid of new user *)
  403.   mtLogin,            (* successful Login/Logout *)
  404.                   (*    From:    uid of old user *)
  405.                   (*    To:      uid of new user *)
  406.                   (*    UserID:  UserID of new user *)
  407.   mtLoginFail,            (* unsuccessful Login/Logout *)
  408.                   (*    From:    uid of old user *)
  409.                   (*    UserID:  UserID of new user *)
  410.   mtPasswd,            (* successful Passwd *)
  411.                   (*    From:    uid of user *)
  412.   mtPasswdFail,            (* unsuccessful Passwd *)
  413.                   (*    From:    uid of user *)
  414.   mtCheckPasswd,        (* successful CheckPasswd *)
  415.                   (*    From:    uid of user *)
  416.   mtCheckPasswdFail        (* unsuccessful CheckPasswd *)
  417.                   (*    From:    uid of user *)
  418.  );
  419.  
  420.  MonitorTriggerSet=SET OF MonitorTriggers;
  421.  
  422.  (* NOTE: This structure may be extended in future! *)
  423.  
  424.  Monitor=RECORD
  425.   node: MinNode;
  426.   mode: MonitorModes;
  427.   triggers: MonitorTriggerSet;
  428.   CASE :INTEGER OF
  429.   | 0: task: TaskPtr;        (* for SEND_SIGNAL *)
  430.        signalNum: LONGCARD;
  431.   | 1: port: MsgPortPtr;    (* for SEND_MESSAGE *)
  432.   END;
  433.  END;
  434.  
  435.  MonitorPtr=POINTER TO Monitor;
  436.  
  437. (*
  438.         Monitor Message
  439.     
  440.     
  441.         Sent to the application if SEND_MESSAGE is specified.
  442.         Do NOT forget to reply!
  443. *)
  444.  
  445.  MonMsg=RECORD
  446.   execMsg: Message;
  447.   monitor: MonitorPtr;        (* The monitor that sent the message *)
  448.   trigger: MonitorTriggers;    (* The trigger that caused the message *)
  449.   from: CARDINAL;
  450.   to: CARDINAL;
  451.   userID: ARRAY [0..useridsize-1] OF CHAR;
  452.  END;
  453.  
  454. END MultiUserD.
  455.